const {contextBridge, ipcRenderer} = require('electron')

// 暴露函数外，可以暴露辩论
contextBridge.exposeInMainWorld('versions',{
    node:()=> process.versions.node,
    chrome:()=>process.versions.chrome,
    electron: process.versions.electron
})

contextBridge.exposeInMainWorld('electronAPI',{
    setTitle:(title)=> ipcRenderer.send('set-title',title),
    openFile:()=>ipcRenderer.invoke('dialog:openFile'),
    onUpdateCounter:(callback)=>ipcRenderer.on('update-counter',callback),
    openNewWin:()=>ipcRenderer.send('newWin')

})